home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / launchpadbugs / connector.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  10.3 KB  |  229 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from lpconstants import CONNECTOR, _MODE_WRAPPER
  5. from exceptions import LaunchpadError
  6.  
  7. class LaunchpadConnector(object):
  8.     
  9.     def __init__(self, cls, method = CONNECTOR.MODES.DEFAULT):
  10.         if isinstance(method, str):
  11.             method = method.upper()
  12.             
  13.             try:
  14.                 method = getattr(CONNECTOR.MODES, method)
  15.             except AttributeError:
  16.                 raise NotImplementedError, "Connection method '%s' not implemented" % method
  17.             except:
  18.                 None<EXCEPTION MATCH>AttributeError
  19.             
  20.  
  21.         None<EXCEPTION MATCH>AttributeError
  22.         self._LaunchpadConnector__method = method
  23.         if not isinstance(self.method, _MODE_WRAPPER):
  24.             raise ValueError
  25.         isinstance(self.method, _MODE_WRAPPER)
  26.         
  27.         try:
  28.             cls_id = CONNECTOR.CONNECTIONS[self.method][cls][0]
  29.         except:
  30.             raise ValueError
  31.  
  32.         
  33.         try:
  34.             self._LaunchpadConnector__module = __import__(cls_id, globals(), locals(), [], -1)
  35.         except TypeError:
  36.             self._LaunchpadConnector__module = __import__(cls_id, globals(), locals(), [])
  37.  
  38.         self._LaunchpadConnector__cls = getattr(self.module, cls)
  39.         
  40.         try:
  41.             connection_id = CONNECTOR.CONNECTIONS[self.method][cls][1]
  42.         except:
  43.             ValueError
  44.  
  45.         
  46.         try:
  47.             mod_connection = __import__(connection_id[0], globals(), locals(), [], -1)
  48.         except TypeError:
  49.             mod_connection = __import__(connection_id[0], globals(), locals(), [])
  50.  
  51.         self._LaunchpadConnector__connection = getattr(mod_connection, connection_id[1])()
  52.  
  53.     
  54.     def connection(self):
  55.         return self._LaunchpadConnector__connection
  56.  
  57.     connection = property(connection)
  58.     
  59.     def set_connection_mode(self, mode):
  60.         self.connection.set_mode(mode)
  61.  
  62.     
  63.     def get_auth(self):
  64.         return self.connection.get_auth()
  65.  
  66.     
  67.     def set_auth(self, auth):
  68.         self.connection.set_auth(auth)
  69.  
  70.     authentication = property(get_auth, set_auth)
  71.     
  72.     def cls(self):
  73.         return self._LaunchpadConnector__cls
  74.  
  75.     cls = property(cls)
  76.     
  77.     def method(self):
  78.         return self._LaunchpadConnector__method
  79.  
  80.     method = property(method)
  81.     
  82.     def module(self):
  83.         return self._LaunchpadConnector__module
  84.  
  85.     module = property(module)
  86.     
  87.     def needs_login(self):
  88.         return self.connection.needs_login()
  89.  
  90.     needs_login = property(needs_login)
  91.     
  92.     class Error:
  93.         LPUrlError = LaunchpadError
  94.  
  95.  
  96.  
  97. class ConnectBug(LaunchpadConnector):
  98.     
  99.     def __init__(self, method = CONNECTOR.MODES.DEFAULT):
  100.         LaunchpadConnector.__init__(self, 'Bug', method)
  101.  
  102.     
  103.     def __call__(self, bug = None, url = None):
  104.         return self.cls(bug, url, connection = self.connection)
  105.  
  106.     
  107.     def content_types(self):
  108.         return self.connection.content_types
  109.  
  110.     content_types = property(content_types)
  111.     
  112.     def NewAttachment(self, *args, **kwargs):
  113.         ''' returns a Attachment-class '''
  114.         if self.method == CONNECTOR.MODES.TEXT:
  115.             raise NotImplementedError, 'It is impossible to add attachments in the text-mode'
  116.         self.method == CONNECTOR.MODES.TEXT
  117.         return getattr(self.module, 'Attachment')(connection = self.connection, *args, **kwargs)
  118.  
  119.     
  120.     def NewComment(self, *args, **kwargs):
  121.         ''' returns a Comment-object '''
  122.         if self.method == CONNECTOR.MODES.TEXT:
  123.             raise NotImplementedError, 'It is impossible to add comments in the text-mode'
  124.         self.method == CONNECTOR.MODES.TEXT
  125.         return getattr(self.module, 'Comment')(*args, **kwargs)
  126.  
  127.     
  128.     def NewTask(self, task_type, *args, **kwargs):
  129.         ''' returns a Comment-object '''
  130.         if self.method == CONNECTOR.MODES.TEXT:
  131.             raise NotImplementedError, 'It is impossible to add a task in the text-mode'
  132.         self.method == CONNECTOR.MODES.TEXT
  133.         
  134.         try:
  135.             return getattr(self.module, 'create_%s_task' % task_type.lower())(*args, **kwargs)
  136.         except AttributeError:
  137.             raise NotImplementedError, "creating of new '%s'-tasks is not implemented" % task_type
  138.  
  139.  
  140.     
  141.     def New(self, *args, **kwargs):
  142.         ''' returns a Bug-object '''
  143.         if self.method == CONNECTOR.MODES.TEXT:
  144.             raise NotImplementedError, 'It is impossible to create bugreports in the text-mode'
  145.         self.method == CONNECTOR.MODES.TEXT
  146.         return getattr(self.module, 'create_new_bugreport')(connection = self.connection, *args, **kwargs)
  147.  
  148.  
  149.  
  150. class ConnectBugList(LaunchpadConnector):
  151.     
  152.     def __init__(self, method = CONNECTOR.MODES.DEFAULT, all_tasks = False):
  153.         LaunchpadConnector.__init__(self, 'BugList', method)
  154.         self._ConnectBugList__all_tasks = all_tasks
  155.         self._ConnectBugList__progress_hook = None
  156.  
  157.     
  158.     def __call__(self, baseurl = None):
  159.         return self.cls(baseurl, connection = self.connection, all_tasks = self._ConnectBugList__all_tasks, progress_hook = self._ConnectBugList__progress_hook)
  160.  
  161.     
  162.     def set_progress_hook(self, progress_hook, blocksize = 25):
  163.         self._ConnectBugList__progress_hook = self.cls._create_progress_hook(progress_hook, blocksize)
  164.  
  165.  
  166.  
  167. def ConnectTaskList(method = CONNECTOR.MODES.DEFAULT):
  168.     return ConnectBugList(method, all_tasks = True)
  169.  
  170.  
  171. class ConnectBlueprint(LaunchpadConnector):
  172.     
  173.     def __init__(self, method = CONNECTOR.MODES.DEFAULT):
  174.         LaunchpadConnector.__init__(self, 'Blueprint', method)
  175.  
  176.     
  177.     def __call__(self, url):
  178.         return self.cls(url, self.connection)
  179.  
  180.  
  181.  
  182. class ConnectBlueprintList(LaunchpadConnector):
  183.     
  184.     def __init__(self, method = CONNECTOR.MODES.DEFAULT):
  185.         LaunchpadConnector.__init__(self, 'BlueprintList', method)
  186.         self._ConnectBlueprintList__progress_hook = None
  187.  
  188.     
  189.     def __call__(self, baseurl = None):
  190.         return self.cls(baseurl, connection = self.connection, progress_hook = self._ConnectBlueprintList__progress_hook)
  191.  
  192.     
  193.     def set_progress_hook(self, progress_hook, blocksize = 25):
  194.         self._ConnectBlueprintList__progress_hook = self.cls._create_progress_hook(progress_hook, blocksize)
  195.  
  196.  
  197.  
  198. class ConnectProjectList(LaunchpadConnector):
  199.     
  200.     def __init__(self, method = CONNECTOR.MODES.DEFAULT):
  201.         LaunchpadConnector.__init__(self, 'ProjectList', method)
  202.         self._ConnectProjectList__progress_hook = None
  203.  
  204.     
  205.     def __call__(self, baseurl = None):
  206.         return self.cls(baseurl, connection = self.connection, all_tasks = False, progress_hook = self._ConnectProjectList__progress_hook)
  207.  
  208.     
  209.     def set_progress_hook(self, progress_hook, blocksize = 25):
  210.         self._ConnectProjectList__progress_hook = self.cls._create_progress_hook(progress_hook, blocksize)
  211.  
  212.  
  213.  
  214. class ConnectProjectPackageList(LaunchpadConnector):
  215.     
  216.     def __init__(self, method = CONNECTOR.MODES.DEFAULT):
  217.         LaunchpadConnector.__init__(self, 'ProjectPackageList', method)
  218.         self._ConnectProjectPackageList__progress_hook = None
  219.  
  220.     
  221.     def __call__(self, baseurl = None):
  222.         return self.cls(baseurl, connection = self.connection, all_tasks = False, progress_hook = self._ConnectProjectPackageList__progress_hook)
  223.  
  224.     
  225.     def set_progress_hook(self, progress_hook, blocksize = 25):
  226.         self._ConnectProjectPackageList__progress_hook = self.cls._create_progress_hook(progress_hook, blocksize)
  227.  
  228.  
  229.